//
//  DemoPageControllerCell.m
//  UniverseProject
//
//  Created by king on 2021/6/17.
//  Copyright © 2021 Cloud2209. All rights reserved.
//

#import "DemoPageControllerCell.h"

#pragma mark - cellView

@interface DemoPageControllerCell()

@property (nonatomic, weak)UIButton *commenSwitch;
@end

@implementation DemoPageControllerCell

- (void)initViews{
    UIView *boxView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, K_SCREEN_WIDTH, 300)];
    
    UILabel *countLab = [UILabel labelWithTitle:@"1024" color:LGCOLOR(@"000000") font:LGFONT(44)];
    countLab.frame = CGRectMake(0, 0, K_SCREEN_WIDTH, 44);
    countLab.textAlignment = 1;
    [boxView addSubview:countLab];
    self.countLab = countLab;
    [self.contentView addSubview:boxView];
    self.boxView = boxView;
    countLab.center = boxView.center;
    
    UIButton *commenSwitch = [UIButton new];
    commenSwitch.backgroundColor = [UIColor redColor];
    [commenSwitch addTarget:self action:@selector(notiKeyboard)];
    [self.contentView addSubview:commenSwitch];
    self.commenSwitch = commenSwitch;
}



- (void)setModel_str:(NSString *)model_str{
    _model_str = model_str;
    
    //去除重用
    [self.crv removeFromSuperview];
    
    ChatRoomView *crv = [[ChatRoomView alloc] initWithFrame:CGRectMake(0, _boxView.bottom, K_SCREEN_WIDTH, K_SCREEN_HEIGHT - 300 -k_SafeAreaTopHeight - 64)];
//    crv.backgroundColor = [UIColor cyanColor];
    [self.contentView insertSubview:crv belowSubview:self.boxView];
    self.crv = crv;
//    [self.contentView bringSubviewToFront:self.boxView];
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    
    self.crv.frame = CGRectMake(0, _boxView.bottom, K_SCREEN_WIDTH, K_SCREEN_HEIGHT - 300 -k_SafeAreaTopHeight - 64);
    
    self.commenSwitch.frame = CGRectMake(15, self.crv.bottom, K_SCREEN_WIDTH - 30, 44);
}


//通知唤醒键盘
- (void)notiKeyboard{
    
    if (self.callKeyboard) {
        self.callKeyboard();
    }
}

#pragma mark - 屏幕事件处理
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"通知DemoPageController收起键盘" object:nil];
    
    [self.crv showEnterpriseInfo];
    
}



@end


